{template '../../header'}
{template '../../left'}

<div class="card">
    <div class="card-header">
        修改广告
    </div>
    <div class="card-body">
        <form method="post">
            <div class="row">
                <div class="col-6">
                    <div class="form-group">
                        <label>位置</label>
                        <select name="position" class="form-control form-control-sm">
                            {loop $positions $key $value}
                            <option value="{$key}" {if $detail['position']==$key}selected{/if}>{$value}</option>
                            {/loop}
                        </select>
                    </div>
                    <div class="form-group">
                        <label>标题</label>
                        <input class="form-control form-control-sm" type="text" maxlength="50" name="title" value="{$detail['title']}">
                    </div>
                    <div class="form-group">
                        <label>链接</label>
                        <input class="form-control form-control-sm" type="text" name="url" value="{$detail['url']}">
                    </div>
                    <div class="form-group">
                        <label>排序</label>
                        <input type="text" name="sort" class="form-control form-control-sm" value="{$detail['sort']}">
                    </div>
                    <div class="form-group">
                        <label>是否显示</label>
                        <select name="state" class="form-control form-control-sm">
                            {loop $states $key $value}
                            <option value="{$key}" {if $detail['state']==$key}selected{/if}>{$value}</option>
                            {/loop}
                        </select>
                    </div>
                </div>
                <div class="col-6">
                    <div class="form-group">
                        <label>
                            图片
                            <span class="badge badge-pill badge-info" data-toggle="tooltip" data-placement="top" title="" data-original-title="图片宽高比2:1">?</span>
                        </label>
                        <div class="form-control-static">
                            <label id="preview" class="preview banner">
                                +<input type="file" id="file" accept="image/*" />
                                <input type="hidden" id="thumb" name="image" value="{$detail['image']}" />
                            </label>
                            <script type="text/javascript">
                                var loading;
                                $("#file").uploadImagePreview({
                                    destID: "preview",
                                    imgUrl: "{$detail['image']}",
                                    server: "/admin/upload/base64?dir=cms/ads",
                                    change: function (image) {
                                        $("#thumb").val(image);
                                    },
                                    startUpload: function () {
                                        loading = $.loading({title: '正在上传...'});
                                    },
                                    finishUpload: function () {
                                        loading.unloading();
                                    },
                                });
                            </script>
                        </div>
                    </div>
                </div>
            </div>
            <button type="submit" class="btn btn-success btn-sm"><i class="fa fa-save"></i> 保存</button>
        </form>
    </div>
</div>

{template '../../footer'}   